<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class plogfile extends CI_Controller {

	private $all_session;
	private $mem_type;
	private $data;

	public function __construct()
    {
        parent::__construct();

        @$this->all_session = $this->session->all_userdata();  
        @$this->mem_type = $this->all_session['login'][0]['mem_type'];   

        if($this->mem_type != 2)
        {
        	redirect('authen');
        } 
    }
	
	public function index()
	{
		$all_session = $this->session->all_userdata();
		//////////////////////////////////////////////////////
		//////////////////// pagination //////////////////////
		//////////////////////////////////////////////////////

		$this->load->library('pagination');
		$config['first_tag_open'] = $config['last_tag_open']= $config['next_tag_open']= $config['prev_tag_open'] = $config['num_tag_open'] = '<li>';
        $config['first_tag_close'] = $config['last_tag_close']= $config['next_tag_close']= $config['prev_tag_close'] = $config['num_tag_close'] = '</li>';
        $config['cur_tag_open'] = "<li><span><b>";
        $config['cur_tag_close'] = "</b></span></li>";

		$config['base_url'] = base_url().'index.php/plogfile/index';
		$config['per_page'] = 50;
		
				 
		$per_page = $config['per_page'];
		$uri = $this->uri->segment(3);



		//////////////////////////////////////////////////////
		////////////// sorting by log_status /////////////////
		//////////////////////////////////////////////////////
		if($this->input->post('log_status') == null)
		{
			$log_status = 'all';

			if(@$all_session['log_status'] != null)
			{
				$log_status = $all_session['log_status'];
			}



		} else {
			$log_status = $this->input->post('log_status');			
			$session['log_status'] = $log_status;
			$this->session->set_userdata($session);
			
		}
		$config['total_rows'] = count($this->logfile_model->count_logfile($log_status));

		$this->data['log_file'] = $this->logfile_model->get_logfile($log_status ,$per_page ,$uri);

		$this->pagination->initialize($config);
		$this->load->view('plogfile' ,$this->data);
	}
}